<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css"/>




  <link href="//fonts.useso.com/css?family=Lato:300,400,700,400italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">



<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=0.5.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="linux,web," />





  <link rel="alternate" href="/atom.xml" title="Lippi-浮生志" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=0.5.0" />






<meta name="description" content="安装Apache">
<meta property="og:type" content="article">
<meta property="og:title" content="Ubuntu下Apache服务器的配置">
<meta property="og:url" content="http://www.ezlippi.com/blog/2016/01/apache-configuration-in-ubuntu.html">
<meta property="og:site_name" content="Lippi-浮生志">
<meta property="og:description" content="安装Apache">
<meta property="og:updated_time" content="2016-02-29T13:53:50.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Ubuntu下Apache服务器的配置">
<meta name="twitter:description" content="安装Apache">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>

  <title> Ubuntu下Apache服务器的配置 | Lippi-浮生志 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?340874ba9357cbe81570aa4ac1185941";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>






  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner">
<script>
(function(){
    var bp = document.createElement('script');
    bp.src = '//push.zhanzhang.baidu.com/push.js';
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
            
<div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">Lippi-浮生志</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle"></p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu menu-left">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-home fa-fw"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-th fa-fw"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-archive fa-fw"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-tags fa-fw"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-user fa-fw"></i> <br />
            
            关于
          </a>
        </li>
      

      
      
      
    </ul>
  

  
    <div class="site-search">
      
  <form class="site-search-form">
  <input type="text" id="st-search-input" class="st-search-input st-default-search-input" />
</form>

<script type="text/javascript">
  (function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
    (w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
    e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
  })(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

  _st('install', 'fLM9qfxyerC6njvM7usy','2.0.0');
</script>



    </div>
  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                Ubuntu下Apache服务器的配置
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-01-20T00:00:00+08:00" content="2016-01-20">
              2016-01-20
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Unix-Linux/" itemprop="url" rel="index">
                    <span itemprop="name">Unix/Linux</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/blog/2016/01/apache-configuration-in-ubuntu.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="/blog/2016/01/apache-configuration-in-ubuntu.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          
	
	<span id="busuanzi_container_page_pv" class="post-meta-item-text">
		&nbsp; | &nbsp;  
	    <span id="busuanzi_value_page_pv"><i class="fa fa-spinner fa-spin"></i></span> Hits
	</span>
        </div>
      </header>
    
	


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="安装Apache"><a href="#安装Apache" class="headerlink" title="安装Apache"></a>安装Apache</h2><a id="more"></a>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get update</span><br><span class="line">sudo apt-get install apache2</span><br><span class="line">``` </span><br><span class="line"></span><br><span class="line">打开浏览器输入你的IP地址或者localhost,就会进入到Apache服务器的默认Index页面。结果如下所示：</span><br><span class="line"></span><br><span class="line">&gt; It works!</span><br><span class="line">&gt; This is the default web page <span class="keyword">for</span> this server.</span><br><span class="line">&gt; The web server software is running but no content has been added, yet.</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">## 配置文件</span></span><br><span class="line"></span><br><span class="line">在Ubuntu系统下Apache的主要配置文件在/etc/apache2文件夹下：</span><br><span class="line"></span><br><span class="line">``` bash</span><br><span class="line"><span class="built_in">cd</span> /etc/apache2</span><br><span class="line">ls -F</span><br></pre></td></tr></table></figure>
<blockquote>
<p>apache2.conf  envvars     magic            mods-enabled/  sites-available/<br>conf.d/       httpd.conf  mods-available/  ports.conf     sites-enabled/</p>
</blockquote>
<p>这个目录下有许多纯文本文件和子目录，基本作用如下：</p>
<ul>
<li>apache2.conf:这是服务器的主要配置文件，几乎所有的配置都通过这个文件来完成，但是为了简洁推荐使用单独的指定的文件来配置不同的模块。</li>
<li>ports.conf:这个文件用来指定虚拟主机监听的端口号，如果你配置了SSL的时候要检查这个文件是否正确。</li>
<li>conf.d/:这个目录用来控制Apache的一些特殊配置，比如SSL配置。</li>
<li>sites-available/:这个目录包括所有不同web站点的虚拟主机文件，不同的请求对应不同的内容，这些都是已有的，并不是正在使用的。</li>
<li>sites-enabled/:这个目录包含正在使用的虚拟主机的定义，通常只包含到sites-available目录下文件的符号链接。</li>
<li>mods-[enabled,available]/:和上面的类似，只不过这里面包含的是可用的模块。</li>
</ul>
<p>从Apache的配置目录结构可以知道，它并不是通过单一的文件来配置，贰拾通过模块化来把整个系统拆分成不同的功能，从而能够动态地增加和修改功能。</p>
<h2 id="深入Apache2-conf文件内容"><a href="#深入Apache2-conf文件内容" class="headerlink" title="深入Apache2.conf文件内容"></a>深入Apache2.conf文件内容</h2><p>文件主要分成三部分，全局配置、默认服务器配置和虚拟主机配置，在Ubuntu系统下，这个文件主要负责全局配置，默认服务器和虚拟主机可以通过Include语句来处理。</p>
<p>Include语句允许Apache读取其他配置文件的内容到当前位置，结果就是Apache启动的时候动态生成一个配置文件，如果拉到文件底部会看到很多Include语句，比如ports.conf等。</p>
<h3 id="全局配置"><a href="#全局配置" class="headerlink" title="全局配置"></a>全局配置</h3><h4 id="Timeout"><a href="#Timeout" class="headerlink" title="Timeout"></a>Timeout</h4><p>这个参数默认设置为300，意思是服务器有300s来处理每个请求。</p>
<h4 id="KeepAlive"><a href="#KeepAlive" class="headerlink" title="KeepAlive"></a>KeepAlive</h4><p>如果设置为On，将允许同个客户端每个连接一直保持来处理多个请求(HTTP长连接)</p>
<h4 id="MaxKeepAliveRequests"><a href="#MaxKeepAliveRequests" class="headerlink" title="MaxKeepAliveRequests"></a>MaxKeepAliveRequests</h4><p>这个参数用来设置每个连接最多能处理多少个单独的请求</p>
<h4 id="KeepAliveTimeout"><a href="#KeepAliveTimeout" class="headerlink" title="KeepAliveTimeout"></a>KeepAliveTimeout</h4><p>这个参数设置下一个请求来之前来等待多久，超过这个时间自动关闭这个connection。</p>
<h2 id="MPM-配置"><a href="#MPM-配置" class="headerlink" title="MPM 配置"></a>MPM 配置</h2><p>Ubuntu 14.04下MPM(Multi-Processing Module)配置默认采用了event module,如果你系统采用的是prefork module,可以通过如下方法来切换：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">sudo a2dismod mpm_prefork</span><br><span class="line">sudo a2enmod mpm_event</span><br><span class="line">sudo service apache2 restart</span><br></pre></td></tr></table></figure>
<h2 id="配置虚拟主机"><a href="#配置虚拟主机" class="headerlink" title="配置虚拟主机"></a>配置虚拟主机</h2><p>1.首先禁用默认的Apache虚拟主机：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo a2dissite <span class="number">000</span>-default.conf</span><br></pre></td></tr></table></figure>
<p>2.在/etc/apache2/sites-available目录下创建一个example.com.conf文件，把example.com替换成你的域名：</p>
<p>文件：/etc/apache2/sites-available/example.com.conf</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&lt;VirtualHost *:<span class="number">80</span>&gt; </span><br><span class="line">  ServerAdmin webmaster@example.com</span><br><span class="line">  ServerName example.com</span><br><span class="line">  ServerAlias www.example.com</span><br><span class="line">  DocumentRoot /var/www/example.com/public_html/</span><br><span class="line">  ErrorLog /var/www/example.com/logs/error.log </span><br><span class="line">  CustomLog /var/www/example.com/logs/access.log combined</span><br><span class="line"> &lt;/VirtualHost&gt;</span><br></pre></td></tr></table></figure>
<p> 3.给你的网站内容和日志文件创建目录，把example.com替换成你的域名：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo mkdir -p /var/www/example.com/public_html</span><br><span class="line">sudo mkdir /var/www/example.com/logs</span><br></pre></td></tr></table></figure>
<p> 4.启用这个站点：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo a2ensite example.com.conf</span><br></pre></td></tr></table></figure>
<p> 5.重启Apache</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo service apache2 restart</span><br></pre></td></tr></table></figure>
<p> <em>安装对脚本语言的支持</em></p>
<ul>
<li>Perl support:</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install libapache2-mod-perl2</span><br></pre></td></tr></table></figure>
<ul>
<li>Python support:</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install libapache2-mod-python</span><br></pre></td></tr></table></figure>
<ul>
<li>PHP support:</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install libapache2-mod-php5 php5 php-pear php5-xcache</span><br></pre></td></tr></table></figure>
<h3 id="Apache中启用和禁用网站和模块"><a href="#Apache中启用和禁用网站和模块" class="headerlink" title="Apache中启用和禁用网站和模块"></a>Apache中启用和禁用网站和模块</h3><p>1.启用和禁用网站：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo a2ensite 虚拟主机文件名(example.com.conf)</span><br><span class="line">sudo a2dissite 虚拟主机文件名(example.com.conf)</span><br></pre></td></tr></table></figure>
<p>2.启用和禁用模块</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo a2enmod 模块配置文件名</span><br><span class="line">sudo a2dismod  模块配置文件名</span><br></pre></td></tr></table></figure>
<h2 id="启用用户文件夹实现文件服务器的功能"><a href="#启用用户文件夹实现文件服务器的功能" class="headerlink" title="启用用户文件夹实现文件服务器的功能"></a>启用用户文件夹实现文件服务器的功能</h2><p>1.使用如下命令启用userdir模块:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo a2enmod userdir</span><br></pre></td></tr></table></figure>
<p>2.编辑userdir.conf配置userdir模块:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vim /etc/apache2/mods-enabled/userdir.conf</span><br></pre></td></tr></table></figure>
<p>内容如下，把public_html改为你的个人文件夹名称，如果不存在则创建：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">&lt;IfModule mod_userdir.c&gt;</span><br><span class="line">        UserDir public_html</span><br><span class="line">        UserDir disabled root</span><br><span class="line"> </span><br><span class="line">        &lt;Directory /home/*/public_html&gt;</span><br><span class="line">		AllowOverride All</span><br><span class="line">		Options MultiViews Indexes SymLinksIfOwnerMatch</span><br><span class="line">		&lt;Limit GET POST OPTIONS&gt;</span><br><span class="line">			<span class="comment"># Apache &lt;= 2.2:</span></span><br><span class="line">		        Order allow,deny</span><br><span class="line">		        Allow from all</span><br><span class="line"> </span><br><span class="line">		        <span class="comment"># Apache &gt;= 2.4:</span></span><br><span class="line">		        <span class="comment">#Require all granted</span></span><br><span class="line">		&lt;/Limit&gt;</span><br><span class="line">		&lt;LimitExcept GET POST OPTIONS&gt;</span><br><span class="line">			<span class="comment"># Apache &lt;= 2.2:</span></span><br><span class="line">		        Order deny,allow</span><br><span class="line">		        Deny from all</span><br><span class="line"> </span><br><span class="line">			<span class="comment"># Apache &gt;= 2.4:</span></span><br><span class="line">			<span class="comment">#Require all denied</span></span><br><span class="line">		&lt;/LimitExcept&gt;</span><br><span class="line">        &lt;/Directory&gt;</span><br><span class="line">&lt;/IfModule&gt;</span><br></pre></td></tr></table></figure>
<p>3.创建个人文件夹并重启APache</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo service apache2 restart</span><br><span class="line">mkdir /home/<span class="variable">$USER</span>/public_html</span><br></pre></td></tr></table></figure>
<p>接下来在浏览器中输入<a href="http://localhost/~username/就可以访问你的个人文件夹了，把username替换为你的用户名。" target="_blank" rel="external">http://localhost/~username/就可以访问你的个人文件夹了，把username替换为你的用户名。</a></p>
<h3 id="给你的文件添加访问权限"><a href="#给你的文件添加访问权限" class="headerlink" title="给你的文件添加访问权限"></a>给你的文件添加访问权限</h3><p>把上面的AllowOverride All改为AllowOverride AuthConfig,然后给你的服务器添加认证用户，认证用户保存在/var/www/passwd/中，需要使用htpasswd命令来添加用户，如下所示：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">htpasswd -c /var/www/passwd/public_html lippi </span><br><span class="line">New password: mypassword</span><br><span class="line">Re-type new password: mypassword</span><br><span class="line">Adding password <span class="keyword">for</span> user lippi</span><br></pre></td></tr></table></figure>
<p>最后的userdir.conf是这样的：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">&lt;IfModule mod_userdir.c&gt;</span><br><span class="line">	UserDir public_html </span><br><span class="line">	UserDir disabled root</span><br><span class="line"></span><br><span class="line">	&lt;Directory /home/*/public_html&gt;</span><br><span class="line">		AllowOverride FileInfo AuthConfig Limit Indexes</span><br><span class="line">		Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec</span><br><span class="line">		&lt;Limit GET POST OPTIONS&gt;</span><br><span class="line"><span class="comment">#		Require all granted</span></span><br><span class="line">			AuthType Basic</span><br><span class="line">			AuthName <span class="string">"lippi"</span></span><br><span class="line">			AuthUserFile /var/www/passwd/public_html</span><br><span class="line">			Require valid-user</span><br><span class="line">		&lt;/Limit&gt;</span><br><span class="line">		&lt;LimitExcept GET POST OPTIONS&gt;</span><br><span class="line">			Require all denied</span><br><span class="line">		&lt;/LimitExcept&gt;</span><br><span class="line">	&lt;/Directory&gt;</span><br><span class="line">&lt;/IfModule&gt;</span><br></pre></td></tr></table></figure>

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/linux/" rel="tag">#linux</a>
          
            <a href="/tags/web/" rel="tag">#web</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2016/01/tmux-guide.html" rel="next" title="终端复用软件之tmux简介">
                <i class="fa fa-chevron-left"></i> 终端复用软件之tmux简介
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2016/02/baidu-spider-forbidden.html" rel="prev" title="解决百度爬虫无法抓取github pages">
                解决百度爬虫无法抓取github pages <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="/blog/2016/01/apache-configuration-in-ubuntu.html"
     data-title="Ubuntu下Apache服务器的配置"
     data-content=""
     data-url="http://www.ezlippi.com//blog/2016/01/apache-configuration-in-ubuntu.html">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          

  <p>热评文章</p>
  <div class="ds-top-threads" data-range="weekly" data-num-items="4"></div>


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="/blog/2016/01/apache-configuration-in-ubuntu.html"
           data-title="Ubuntu下Apache服务器的配置" data-url="http://www.ezlippi.com//blog/2016/01/apache-configuration-in-ubuntu.html">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.jpg"
               alt="EZLippi" />
          <p class="site-author-name" itemprop="name">EZLippi</p>
          <p class="site-description motion-element" itemprop="description">Easy Lippi</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">63</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>
          
          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">22</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">69</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/EZLippi" target="_blank">
                  
                    <i class="fa fa-github"></i> GitHub
                  
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/ouyanglip" target="_blank">
                  
                    <i class="fa fa-weibo"></i> weibo
                  
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/lippi-ouyang" target="_blank">
                  
                    <i class="fa fa-weibo"></i> zhihu
                  
                </a>
              </span>
            
          
        </div>

        
        

        <div class="links-of-author motion-element">
          
            <p class="site-author-name">友情链接</p>
            
              <span class="links-of-author-item">
                <a href="http://szhshp.org" target="_blank">szhshp的博客</a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.zhihu.com/people/lippi-ouyang" target="_blank">友链出租</a>
              </span>
            
          
        </div>

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc-indicator-top post-toc-indicator">
            <i class="fa fa-angle-double-up"></i>
          </div>
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#安装Apache"><span class="nav-number">1.</span> <span class="nav-text">安装Apache</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#深入Apache2-conf文件内容"><span class="nav-number">2.</span> <span class="nav-text">深入Apache2.conf文件内容</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#全局配置"><span class="nav-number">2.1.</span> <span class="nav-text">全局配置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#Timeout"><span class="nav-number">2.1.1.</span> <span class="nav-text">Timeout</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#KeepAlive"><span class="nav-number">2.1.2.</span> <span class="nav-text">KeepAlive</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#MaxKeepAliveRequests"><span class="nav-number">2.1.3.</span> <span class="nav-text">MaxKeepAliveRequests</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#KeepAliveTimeout"><span class="nav-number">2.1.4.</span> <span class="nav-text">KeepAliveTimeout</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#MPM-配置"><span class="nav-number">3.</span> <span class="nav-text">MPM 配置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置虚拟主机"><span class="nav-number">4.</span> <span class="nav-text">配置虚拟主机</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Apache中启用和禁用网站和模块"><span class="nav-number">4.1.</span> <span class="nav-text">Apache中启用和禁用网站和模块</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#启用用户文件夹实现文件服务器的功能"><span class="nav-number">5.</span> <span class="nav-text">启用用户文件夹实现文件服务器的功能</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#给你的文件添加访问权限"><span class="nav-number">5.1.</span> <span class="nav-text">给你的文件添加访问权限</span></a></li></ol></li></ol></div>
            
          </div>
          <div class="post-toc-indicator-bottom post-toc-indicator">
            <i class="fa fa-angle-double-down"></i>
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2014 - 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">EZLippi</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
   托管在 -
  <a class="theme-link" href="https://github.com/EZLippi/EZLippi.github.io">
    Github
  </a>

</div>
<div class="theme-info">
<span id="busuanzi_container_site_pv">
    &nbsp; | &nbsp;本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
</div>
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>



      </div>
    </footer>

    <div class="back-to-top"></div>
  </div>

  


  



  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  <script type="text/javascript" src="/vendors/velocity/velocity.min.js"></script>

  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js"></script>

  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=0.5.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=0.5.0"></script>



  
  

  
  
<script type="text/javascript" src="/js/src/scrollspy.js?v=0.5.0"></script>

<script type="text/javascript" id="sidebar.toc.highlight">
  $(document).ready(function () {
    var tocSelector = '.post-toc';
    var $tocSelector = $(tocSelector);
    var activeCurrentSelector = '.active-current';

    $tocSelector
      .on('activate.bs.scrollspy', function () {
        var $currentActiveElement = $(tocSelector + ' .active').last();

        removeCurrentActiveClass();
        $currentActiveElement.addClass('active-current');

        $tocSelector[0].scrollTop = $currentActiveElement.position().top;
      })
      .on('clear.bs.scrollspy', function () {
        removeCurrentActiveClass();
      });

    function removeCurrentActiveClass () {
      $(tocSelector + ' ' + activeCurrentSelector)
        .removeClass(activeCurrentSelector.substring(1));
    }

    function processTOC () {
      getTOCMaxHeight();
      toggleTOCOverflowIndicators();
    }

    function getTOCMaxHeight () {
      var height = $('.sidebar').height() -
                   $tocSelector.position().top -
                   $('.post-toc-indicator-bottom').height();

      $tocSelector.css('height', height);

      return height;
    }

    function toggleTOCOverflowIndicators () {
      tocOverflowIndicator(
        '.post-toc-indicator-top',
        $tocSelector.scrollTop() > 0 ? 'show' : 'hide'
      );

      tocOverflowIndicator(
        '.post-toc-indicator-bottom',
        $tocSelector.scrollTop() >= $tocSelector.find('ol').height() - $tocSelector.height() ? 'hide' : 'show'
      )
    }

    $(document).on('sidebar.motion.complete', function () {
      processTOC();
    });

    $('body').scrollspy({ target: tocSelector });
    $(window).on('resize', function () {
      if ( $('.sidebar').hasClass('sidebar-active') ) {
        processTOC();
      }
    });

    onScroll($tocSelector);

    function onScroll (element) {
      element.on('mousewheel DOMMouseScroll', function (event) {
          var oe = event.originalEvent;
          var delta = oe.wheelDelta || -oe.detail;

          this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
          event.preventDefault();

          toggleTOCOverflowIndicators();
      });
    }

    function tocOverflowIndicator (indicator, action) {
      var $indicator = $(indicator);
      var opacity = action === 'show' ? 1 : 0;
      $indicator.velocity ?
        $indicator.velocity('stop').velocity({
          opacity: opacity
        }, { duration: 100 }) :
        $indicator.stop().animate({
          opacity: opacity
        }, 100);
    }

  });
</script>

<script type="text/javascript" id="sidebar.nav">
  $(document).ready(function () {
    var html = $('html');
    var TAB_ANIMATE_DURATION = 200;
    var hasVelocity = $.isFunction(html.velocity);

    $('.sidebar-nav li').on('click', function () {
      var item = $(this);
      var activeTabClassName = 'sidebar-nav-active';
      var activePanelClassName = 'sidebar-panel-active';
      if (item.hasClass(activeTabClassName)) {
        return;
      }

      var currentTarget = $('.' + activePanelClassName);
      var target = $('.' + item.data('target'));

      hasVelocity ?
        currentTarget.velocity('transition.slideUpOut', TAB_ANIMATE_DURATION, function () {
          target
            .velocity('stop')
            .velocity('transition.slideDownIn', TAB_ANIMATE_DURATION)
            .addClass(activePanelClassName);
        }) :
        currentTarget.animate({ opacity: 0 }, TAB_ANIMATE_DURATION, function () {
          currentTarget.hide();
          target
            .stop()
            .css({'opacity': 0, 'display': 'block'})
            .animate({ opacity: 1 }, TAB_ANIMATE_DURATION, function () {
              currentTarget.removeClass(activePanelClassName);
              target.addClass(activePanelClassName);
            });
        });

      item.siblings().removeClass(activeTabClassName);
      item.addClass(activeTabClassName);
    });

    $('.post-toc a').on('click', function (e) {
      e.preventDefault();
      var targetSelector = NexT.utils.escapeSelector(this.getAttribute('href'));
      var offset = $(targetSelector).offset().top;
      hasVelocity ?
        html.velocity('stop').velocity('scroll', {
          offset: offset  + 'px',
          mobileHA: false
        }) :
        $('html, body').stop().animate({
          scrollTop: offset
        }, 500);
    });

    // Expand sidebar on post detail page by default, when post has a toc.
    NexT.motion.middleWares.sidebar = function () {
      var $tocContent = $('.post-toc-content');

      if (CONFIG.sidebar.display === 'post' || CONFIG.sidebar.display === 'always') {
        if ($tocContent.length > 0 && $tocContent.html().trim().length > 0) {
          NexT.utils.displaySidebar();
        }
      }
    };
  });
</script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=0.5.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"ezlippi"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
  





  
  

  
  


</body>
</html>
